package hutool.bean;

import cn.hutool.Hutool;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.ReflectUtil;
import cn.hutool.json.JSON;
import cn.hutool.json.JSONObject;
import org.apache.poi.ss.formula.functions.T;
import shorturl.entity.ShorterString;

/**
 * @author 黄乾坤
 * @create 2022-07-25 15:45
 */
public class TestMain {

    public static void main(String[] args) {
//        Source source = new Source();
//        source.setS("xxxx");
//        source.setL(11L);
//        source.setShorterString(new ShorterString("11", "11"));
//
//        Target target = new Target();
////        target.setS1("3333");
//        BeanUtil.copyProperties(source, target);
//        System.out.println(target);
//
//        target.getShorterString().setUrl("22");
//        System.out.println(target);
//
//        System.out.println(source);


        int data = 1000;
        System.out.println("data:"+data);
        Long t1 = System.currentTimeMillis();
        org.json.JSONObject jsonObject1 = new org.json.JSONObject();
        for (int i = 0; i < data; i++) {
            jsonObject1.put("k" + i, "v" + i);
        }
        String s1 = jsonObject1.toString();
        Long t2 = System.currentTimeMillis();
        System.out.println("org.json:" + (t2 - t1));

        Long t3 = System.currentTimeMillis();
        net.sf.json.JSONObject jsonObject2 = new net.sf.json.JSONObject();
        for (int i = 0; i < data; i++) {
            jsonObject2.put("k" + i, "v" + i);
        }
        String s2 = jsonObject2.toString();
        Long t4 = System.currentTimeMillis();
        System.out.println("net.sf.json:" + (t4 - t3));

        Long t5 = System.currentTimeMillis();
        com.alibaba.fastjson.JSONObject jsonObject3 = new com.alibaba.fastjson.JSONObject();
        for (int i = 0; i < data; i++) {
            jsonObject3.put("k" + i, "v" + i);
        }
        String s3 = jsonObject3.toString();
        Long t6 = System.currentTimeMillis();
        System.out.println("com.alibaba.fastjson:" + (t6 - t5));

        Long t7 = System.currentTimeMillis();
        com.google.gson.JsonObject jsonObject4 = new com.google.gson.JsonObject();
        for (int i = 0; i < data; i++) {
            jsonObject4.addProperty("k" + i, "v" + i);
        }
        String s4 = jsonObject4.toString();
        Long t8 = System.currentTimeMillis();
        System.out.println("com.google.gson:" + (t8 - t7));

        Long t9 = System.currentTimeMillis();
        cn.hutool.json.JSONObject jsonObject5 = new cn.hutool.json.JSONObject();
        for (int i = 0; i < data; i++) {
            jsonObject5.set("k" + i, "v" + i);
        }
        String s5 = jsonObject5.toString();
        Long t10 = System.currentTimeMillis();
        System.out.println("hutool json:" + (t10 - t9));
    }
}
